/**
 * Created by Administrator on 2017/4/7 0007.
 */
var PageListen={
    create:function () {
        var page={};

        page.ui=new PIXI.DisplayObjectContainer();
        var sp_bg=Easy.CreateSprite('assets/images/pSound_bg.png',0,0,0,0,1);

        sp_bg.on('pointerdown',downHandler);
        page.ui.addChild(sp_bg);

        var t0=new PIXI.Sprite(resource['assets/images/pt0_t0.png'].texture);
        t0.anchor.set(0.5);
        page.ui.addChild(t0);
        t0.x=124;
        t0.y=517;
        var mask_0=new PIXI.Graphics();
        mask_0.beginFill(0,1);
        mask_0.drawCircle(0,0,182);
        mask_0.endFill();
        mask_0.x=t0.x;
        mask_0.y=t0.y;
        mask_0.scale.x=mask_0.scale.y=0;
        page.ui.addChild(mask_0);
        t0.mask=mask_0;

        var t1=new PIXI.Sprite(resource['assets/images/pt0_t1.png'].texture);
        t1.anchor.set(0.5);
        page.ui.addChild(t1);
        t1.x=194;
        t1.y=517;
        var mask_1=new PIXI.Graphics();
        mask_1.beginFill(0,1);
        mask_1.drawCircle(0,0,182);
        mask_1.endFill();
        mask_1.x=t1.x;
        mask_1.y=t1.y;
        mask_1.scale.x=mask_1.scale.y=0;
        page.ui.addChild(mask_1);
        t1.mask=mask_1;

        var t2=new PIXI.Sprite(resource['assets/images/pt0_t2.png'].texture);
        t2.anchor.set(0.5);
        page.ui.addChild(t2);
        t2.x=276;
        t2.y=517;
        var mask_2=new PIXI.Graphics();
        mask_2.beginFill(0,1);
        mask_2.drawCircle(0,0,182);
        mask_2.endFill();
        mask_2.x=t2.x;
        mask_2.y=t2.y;
        mask_2.scale.x=mask_2.scale.y=0;
        page.ui.addChild(mask_2);
        t2.mask=mask_2;

        var t3=new PIXI.Sprite(resource['assets/images/pt0_t3.png'].texture);
        t3.anchor.set(0.5);
        page.ui.addChild(t3);
        t3.x=374;
        t3.y=517;
        var mask_3=new PIXI.Graphics();
        mask_3.beginFill(0,1);
        mask_3.drawCircle(0,0,182);
        mask_3.endFill();
        mask_3.x=t3.x;
        mask_3.y=t3.y;
        mask_3.scale.x=mask_3.scale.y=0;
        page.ui.addChild(mask_3);
        t3.mask=mask_3;

        var t4=new PIXI.Sprite(resource['assets/images/pt0_t4.png'].texture);
        t4.anchor.set(0.5);
        page.ui.addChild(t4);
        t4.x=482;
        t4.y=517;
        var mask_4=new PIXI.Graphics();
        mask_4.beginFill(0,1);
        mask_4.drawCircle(0,0,182);
        mask_4.endFill();
        mask_4.x=t4.x;
        mask_4.y=t4.y;
        mask_4.scale.x=mask_4.scale.y=0;
        page.ui.addChild(mask_4);
        t4.mask=mask_4;

        var t5=new PIXI.Sprite(resource['assets/images/pt0_t5.png'].texture);
        t5.anchor.set(0.5);
        page.ui.addChild(t5);
        t5.x=620;
        t5.y=517;
        var mask_5=new PIXI.Graphics();
        mask_5.beginFill(0,1);
        mask_5.drawCircle(0,0,182);
        mask_5.endFill();
        mask_5.x=t5.x;
        mask_5.y=t5.y;
        mask_5.scale.x=mask_5.scale.y=0;
        page.ui.addChild(mask_5);
        t5.mask=mask_5;

        var click=new PIXI.Sprite(resource['assets/images/click.png'].texture);
        click.alpha=0;
        click.anchor.set(0.5);
        click.x=360;
        click.y=710;
        page.ui.addChild(click);


        function downHandler(e) {
            sp_bg.interactive=false;
            page.ui.parent.removeChild(page.ui)
            document.getElementById('div_video').style.zIndex=4;
            document.getElementById('mVideo').play();
            document.getElementById('mVideo').style.width=740*pixiStage.scale.x+'px';
            document.getElementById('mVideo').style.height=1136*pixiStage.scale.y+'px';
            document.getElementById('mVideo').style.left= pixiStage.x+'px';
            document.getElementById('mVideo').style.top= pixiStage.y+'px';

            var md=document.getElementsByTagName("video")[0];
            md.addEventListener("ended",function(){

                document.dispatchEvent(new CustomEvent('Game_PageIn',{'detail':0}));
                document.getElementById('div_2d').style.zIndex=6;
                document.getElementById('div_video').style.zIndex=5;


                Music["sd"].play();
            });
            // document.getElementById('mVideo').style.width=window.innerWidth;
            // document.getElementById('mVideo').style.width=window.innerWidth;
            // document.getElementById('mVideo').style.height=window.innerHeight;
        }
        page.In=function () {
            t0.scale.x = t0.scale.y = 2.5;
            mask_0.scale.x = mask_0.scale.y = 0;
            TweenMax.to(t0.scale, 1, {delay: 1 + 0.2 * 0, x: 1, y: 1, ease: Cubic.easeOut});
            TweenMax.to(mask_0.scale, 1, {delay: 1 + 0.2 * 0, x: 1, y: 1, ease: Back.easeOut,onComplete:function () {
                t0.mask.alpha=0;
                t0.mask.parent.removeChild(t0.mask);
                t0.mask=null;
            }});

            t1.scale.x = t1.scale.y = 2.5;
            mask_1.scale.x = mask_1.scale.y = 0;
            TweenMax.to(t1.scale, 1, {delay: 1 + 0.2 * 1, x: 1, y: 1, ease: Cubic.easeOut});
            TweenMax.to(mask_1.scale, 1, {delay: 1 + 0.2 * 1, x: 1, y: 1, ease: Back.easeOut,onComplete:function () {
                t1.mask.alpha=0;
                t1.mask.parent.removeChild(t1.mask);
                t1.mask=null;
            }});

            t2.scale.x = t2.scale.y = 2.5;
            mask_2.scale.x = mask_2.scale.y = 0;
            TweenMax.to(t2.scale, 1, {delay: 1 + 0.2 * 2, x: 1, y: 1, ease: Cubic.easeOut});
            TweenMax.to(mask_2.scale, 1, {delay: 1 + 0.2 * 2, x: 1, y: 1, ease: Back.easeOut,onComplete:function () {
                t2.mask.alpha=0;
                t2.mask.parent.removeChild(t2.mask);
                t2.mask=null;
            }});

            t3.scale.x = t3.scale.y = 2.5;
            mask_3.scale.x = mask_3.scale.y = 0;
            TweenMax.to(t3.scale, 1, {delay: 1 + 0.2 * 3, x: 1, y: 1, ease: Cubic.easeOut});
            TweenMax.to(mask_3.scale, 1, {delay: 1 + 0.2 * 3, x: 1, y: 1, ease: Back.easeOut,onComplete:function () {
                t3.mask.alpha=0;
                t3.mask.parent.removeChild(t3.mask);
                t3.mask=null;
            }});

            t4.scale.x = t4.scale.y = 2.5;
            mask_4.scale.x = mask_4.scale.y = 0;
            TweenMax.to(t4.scale, 1, {delay: 1 + 0.2 * 4, x: 1, y: 1, ease: Cubic.easeOut});
            TweenMax.to(mask_4.scale, 1, {delay: 1 + 0.2 * 4, x: 1, y: 1, ease: Back.easeOut,onComplete:function () {
                t4.mask.alpha=0;
                t4.mask.parent.removeChild(t4.mask);
                t4.mask=null;
            }});

            t5.scale.x = t5.scale.y = 2.5;
            mask_5.scale.x = mask_4.scale.y = 0;
            TweenMax.to(t5.scale, 1, {delay: 1 + 0.2 * 5, x: 1, y: 1, ease: Cubic.easeOut});
            TweenMax.to(mask_5.scale, 1, {delay: 1 + 0.2 * 5, x: 1, y: 1, ease: Back.easeOut,onComplete:function () {
                t5.mask.alpha=0;
                t5.mask.parent.removeChild(t5.mask);
                t5.mask=null;
            }});

            click.scale.x=click.scale.y=0.7;
            TweenMax.to(click,1,{delay:2,alpha:1,onComplete:function () {
                sp_bg.interactive=true;
                TweenMax.to(click.scale,0.6,{x:0.6,y:0.6,ease:Cubic.easeInOut,yoyo:true,repeat:-1});
            }})
        }
        return page;
    }
}